{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# GPyOpt: Initial designs\n",
    "\n",
    "### Written by Javier Gonzalez, Amazon Reseach Cambridge\n",
    "\n",
    "\n",
    "*Last updated, July 2017.*"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Before starting the optimization, it is important to initialize the model. This notebook quickly takes you over the available initial designs available in GPyOpt."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "%pylab inline \n",
    "import numpy as np\n",
    "import GPyOpt\n",
    "import GPy\n",
    "from GPyOpt.experiment_design import initial_design\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "func  = GPyOpt.objective_examples.experimentsNd.alpine1(input_dim=2) \n",
    "\n",
    "mixed_domain =[{'name': 'var1_2', 'type': 'continuous', 'domain': (-10,10),'dimensionality': 1},\n",
    "               {'name': 'var5', 'type': 'continuous', 'domain': (-1,5)}]\n",
    "\n",
    "space = GPyOpt.Design_space(mixed_domain)\n",
    "data_init = 500"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "### --- Grid design\n",
    "X = initial_design('grid',space,data_init)\n",
    "plt.plot(X[:,0],X[:,1],'b.')\n",
    "plt.title('Grid design')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "### --- Random initial design\n",
    "X = initial_design('random',space,data_init)\n",
    "plt.plot(X[:,0],X[:,1],'b.')\n",
    "plt.title('Random design')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "### --- Latin design\n",
    "X = initial_design('latin',space,data_init)\n",
    "plt.plot(X[:,0],X[:,1],'b.')\n",
    "plt.title('Latin design')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "### --- Sobol design\n",
    "X = initial_design('sobol',space,data_init)\n",
    "plt.plot(X[:,0],X[:,1],'b.')\n",
    "plt.title('Sobol design')"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
